import React, { useState } from 'react'
import ProTable from '@ant-design/pro-table';
import { Button, Tag, Drawer } from 'antd'
import request from '@/utils/request'
import styles from '../index.less'
import SaveView from './save'
export default () => {

    const [visable, setVisable] = useState(false)
    const columns: any = [
        {
            title: '物流公司',
            dataIndex: 'store_title',
        },
        {
            title: '物流公司网址',
            render: (text: any) => <Tag color="cyan">{text} </Tag>,
            align: "center",
            dataIndex: 'level_title',
            hideInSearch: true,
            valueType: "money"
        },
        {
            title: '排序',
            render: (text: any) => <Tag color="green">{text} </Tag>,
            dataIndex: 'industry_title',
            align: "center",
            hideInSearch: true,
        },
        {
            title: '操作',
            align: "center",
            render: (text: any, record: any) => (
                <>
                    <Button size="small" type="primary" ghost style={{ marginRight: "6px" }}>编辑</Button>
                    <Button size="small" danger>删除</Button>
                </>
            ),
        },
    ];


    return (
        <>
            <ProTable<any>
                options={false}
                toolBarRender={(action, { selectedRows }) => [
                    <Button type="primary" onClick={() => {
                        setVisable(true)
                    }}>
                        添加物流公司
                </Button>
                ]}
                headerTitle={null}
                rowKey="id"
                columns={columns}
                request={(params: any) => request('/store/apply-list', {
                    params,
                })}
                tableAlertRender={false}
                className={styles.antProTable}
            />
            <Drawer
                width="70%"
                title="物流公司"
                placement="right"
                closable={false}
                onClose={() => setVisable(false)}
                visible={visable}
            >
                <SaveView close={() => setVisable(false)} />
            </Drawer>
        </>
    )
}